<template>
	<el-form label-width="150px" :model="form" :rules="rules" ref="queryForm">
		<el-row>
			<el-col :span="12">
				<el-form-item label="行政区域" prop="district">
					<el-select v-model="form.district" size="default" placeholder="请选择" style="width:180px" clearable
						filterable>
						<el-option v-for="item in options" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>
				<el-form-item label="医疗机构总数" prop="sum">
					<el-input v-model="form.sum" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'sum', 0)"></el-input>
				</el-form-item>
				
				<el-form-item label="医院总数" prop="hospitalSum">
					<el-input v-model="form.hospitalSum" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'hospitalSum', 0)"></el-input>
				</el-form-item>
				
				
				
				<el-form-item label="综合医院" prop="generalHospital">
					<el-input v-model="form.generalHospital" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'generalHospital', 0)"></el-input>
				</el-form-item>
				<el-form-item label="中医院" prop="middleHospital">
					<el-input v-model="form.middleHospital" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'middleHospital', 0)"></el-input>
				</el-form-item>
				<el-form-item label="中西医结合医院" prop="zxHospital">
					<el-input v-model="form.zxHospital" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'zxHospital', 0)"></el-input>
				</el-form-item>
				<el-form-item label="专业医院" prop="zyHospital">
					<el-input v-model="form.zyHospital" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'zyHospital', 0)"></el-input>
				</el-form-item>
				<!-- <el-form-item label="护理医院" prop="hlHospital">
					<el-input v-model="form.hlHospital" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'hlHospital', 0)"></el-input>
				</el-form-item> -->
				
				<el-form-item label="基层医疗机构" prop="jcHospiatl">
					<el-input v-model="form.jcHospiatl" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'jcHospiatl', 0)"></el-input>
				</el-form-item>
				
				<el-form-item label="专业卫生公共机构" prop="zySanitation">
					<el-input v-model="form.zySanitation" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'zySanitation', 0)"></el-input>
				</el-form-item>
				
			</el-col>
			<el-col :span="12">

				

				<el-form-item label="其他卫生机构" prop="otherSanitation">
					<el-input v-model="form.otherSanitation" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'otherSanitation', 0)"></el-input>
				</el-form-item>

				<el-form-item label="执业(助理)医师" prop="physician">
					<el-input v-model="form.physician" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'physician', 0)"></el-input>
				</el-form-item>

				<el-form-item label="注册护士" prop="nurse">
					<el-input v-model="form.nurse" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'nurse', 0)"></el-input>
				</el-form-item>

				<el-form-item label="床位总数" prop="bedroom">
					<el-input v-model="form.bedroom" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'bedroom', 0)"></el-input>
				</el-form-item>
				
				
				<el-form-item label="卫生技术人员数量" prop="wsjsrssl">
					<el-input v-model="form.wsjsrssl" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'wsjsrssl', 0)"></el-input>
				</el-form-item>
				<el-form-item label="医院床位数量" prop="yscwsl">
					<el-input v-model="form.yscwsl" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'yscwsl', 0)"></el-input>
				</el-form-item>
				<el-form-item label="基层卫生机构床位数量" prop="jcwsjgcwsl">
					<el-input v-model="form.jcwsjgcwsl" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'jcwsjgcwsl', 0)"></el-input>
				</el-form-item>
				<el-form-item label="专业卫生机构床位数量" prop="zywsjgcwsl">
					<el-input v-model="form.zywsjgcwsl" style="width:180px;"
					@input="e => regOnlyNumSpot(e, form, 'zywsjgcwsl', 0)"></el-input>
				</el-form-item>
				
				

			</el-col>
		</el-row>
		<div style="display: flex;justify-content: flex-end;">
			<el-button @click="closethis()" @keyup.prevent @keydown.enter.prevent>取消</el-button>
			<el-button type="primary" @click="submit(queryForm)" @keyup.prevent @keydown.enter.prevent>确定</el-button>
		</div>
	</el-form>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		ElMessage
	} from 'element-plus'

	import {
		commonInterface
	} from '@/api/common/common'
	
	import {
		regOnlyNumSpot
	} from '@/utils/reg'



	const emit = defineEmits(['getList', 'closeWindow'])
	const props = defineProps(['editData', 'options'])

	const form = ref({})

	const queryForm = ref('')

	const options = ref()

	//必填项
	const rules = reactive({
		district: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "change"
		}]
	})
	//取消
	const closethis = () => {
		emit('closeWindow')
	}

	//确定
	const submit = async (e) => {
		if (!e) return
		await e.validate((valid) => {
			if (valid) {
				let method = 'post'
				if (props.editData) method = 'put'
				commonInterface('/back/renfang/zcbz/counth/', form.value, method).then(result => {
					if (result.code === 200) {
						ElMessage.success(result.msg)
						emit('closeWindow')
						emit('getList')
					} else {
						ElMessage.error(result.msg)
					}
				})
			}
		})
	}

	onMounted(() => {
		options.value = props.options
		if (props.editData) form.value = props.editData
	})
</script>

<style>
</style>